package com.minelx.woods.data.values;

import com.alibaba.fastjson.JSONObject;

import java.util.Objects;

public final class VariantValues {
	private final String name;

	private final JSONObject variables;

	public VariantValues(String name, JSONObject variables) {
		this.name = name;
		this.variables = variables;
	}

	public String getName() {
		return name;
	}

	public JSONObject getVariables() {
		return variables;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		VariantValues that = (VariantValues) o;
		return name.equals(that.name) && variables.equals(that.variables);
	}

	@Override
	public int hashCode() {
		return Objects.hash(name, variables);
	}

	@Override
	public String toString() {
		return "VariantValues{" +
				"name='" + name + '\'' +
				", variables=" + variables +
				'}';
	}

	public static VariantValues fromJSON(JSONObject data) {
		return new VariantValues(
				data.getString("name"),
				data.getJSONObject("variables")
		);
	}
}
